# -*- coding: utf-8 -*-
"""
Web framework/Tornado RequestHandler Class/test03.py
"""
import tornado.web
import asyncio


class IndexHandler(tornado.web.RequestHandler):

    def prepare(self):
        self.r_method = self.request.method

    def on_finish(self) -> None:
        print("This is on_finish function.")

    def get(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def post(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def head(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def delete(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def put(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def patch(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)

    def options(self):
        r_message = f"This is {self.r_method} method."
        print(r_message)
        return self.write(r_message)


async def main():
    app = tornado.web.Application([
        (r'/', IndexHandler)
    ])
    app.listen(8888)
    await asyncio.Event().wait()


if __name__ == "__main__":
    asyncio.run(main())
